package com.lagou.task16;

public class ExceptionFinallyTest {
    //笔试考点
    public static int test(){
        try{
            int[] arr=  new int[5];
            System.out.println(arr[5]);
            return 0;
        }catch (ArrayIndexOutOfBoundsException e){
            e.printStackTrace();
            return  1;
        }finally {
            return 2;
        }
    }
    public static void main(String[] args) {
        try {
            int ia = 10;
            int ib = 0;
            System.out.println(ia / ib);
        }catch (ArithmeticException e){
            e.printStackTrace();
//            String str = null;
//            str.length();
        }finally {
            System.out.println("无论如何我都要走");
        }

        int i1 =  test();
        System.out.println("i1 = " + i1);//i1 = 2
        System.out.println("程序结束了");
    }
}
